package com.lin.manager.controller.system;

import com.lin.manager.aop.Log;
import com.lin.manager.common.enums.LogEnum;
import com.lin.manager.common.resp.R;
import com.lin.manager.system.entity.SysDicEntity;
import com.lin.manager.system.service.SysDicService;
import com.lin.manager.system.model.vo.DictQueryParamVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
* @作者: 林江
* @创建时间: 2024-03-13 14:37:36
* @功能:
*/
@Api(tags = "字典管理")
@RestController
@RequestMapping("dic")
public class SysDicController {

    @Autowired
    SysDicService sysDicService;

    @ApiOperation("字典管理 - 获取所有字典")
    @Log(module = "字典管理", descipt = "获取所有字典", type = LogEnum.SELECT)
    @GetMapping("listPage")
    public R listPage(DictQueryParamVo vo) {
        return R.ok(sysDicService.listPage(vo));
    }

    @ApiOperation("字典管理 - 添加字典")
    @Log(module = "字典管理", descipt = "添加字典", type = LogEnum.INSERT)
    @PostMapping("add")
    public R add(@RequestBody SysDicEntity sysDic) {
        sysDicService.add(sysDic);
        return R.ok();
    }

    @ApiOperation("字典管理 - 修改字典")
    @Log(module = "字典管理", descipt = "修改字典", type = LogEnum.UPDATE)
    @PostMapping("update")
    public R update(@RequestBody SysDicEntity sysDic) {
        sysDicService.update(sysDic);
        return R.ok();
    }

    @ApiOperation("字典管理 - 删除")
    @Log(module = "字典管理", descipt = "删除字典", type = LogEnum.DELETE)
    @DeleteMapping("delete")
    public R del(String id) {
        sysDicService.del(id);
        return R.ok();
    }

}
